import javax.servlet.ServletException;
        import javax.servlet.annotation.WebServlet;
        import javax.servlet.http.HttpServlet;
        import javax.servlet.http.HttpServletRequest;
        import javax.servlet.http.HttpServletResponse;
        import java.io.BufferedReader;
        import java.io.IOException;
        import java.util.Arrays;
        import java.util.Map;
        import java.util.Set;

@WebServlet("/login")
public class login extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("get      >>>");
        String username = paramsArr[0].split("=")[1];
        String password = paramsArr[1].split("=")[1];
        String paramsStr = req.getQueryString();
        String[] paramsArr = paramsStr.split("&");
        if ("admin".equals(username) && "admin".equals(password)) {
            System.out.println("恭喜你，登录成功！");
        } else {
            System.out.println("很抱歉，登录失败!");
        }
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("post     >>>");
        String line;
        BufferedReader reader = req.getReader();
        while ((line = reader.readLine()) != null) {
            System.out.println(line);
            String[] paramsArr = line.split("&");
            String password = paramsArr[1].split("=")[1];
            String username = paramsArr[0].split("=")[1];
            if ("admin".equals(username) && "admin".equals(password)) {
                System.out.println("登录成功！");
            } else {
                System.out.println("登录失败!");
            }
        }
    }
}